home *** CD-ROM | disk | FTP | other *** search
/ Resource for Source: Assembly / assembly resource for source.iso / assem01 / enetbios.asm < prev    next >
Assembly Source File  |  1995-11-01  |  10KB  |  226 lines

  1. TITLE     'ENETBIOS - resident program to display NETBIOS commands
  2. ;----------------------------------------------------------------------
  3. ;  This program will get the second byte (NCB command field) and
  4. ;   compare this field against the fn_table. If there is a match then
  5. ;   the message which corresponds with the byte is diplayed on the CRT.
  6. ;
  7. ;   The display starts at column 45 and ranges between lines 0 and 23.
  8. ;   When the line reaches the bottom it starts at the top leaving an
  9. ;   audit trail which can help you in determining NETBIOS problems.
  10. ;----------------------------------------------------------------------
  11. CSEG    SEGMENT PARA PUBLIC 'CODE'
  12.         ASSUME  CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG
  13.         ORG     100H
  14. START:
  15.         JMP   INITIALIZE
  16.  
  17. COPYRIGHT    DB    "ENETBIOS 1.00 (c) Ziff Communications Co.",13,10
  18.         DB    "PC Magazine ",254," Randol Tigrett","$",26
  19.  
  20. OLD_NETBIOS       DD ?                           ;store old interrupt
  21. NCBLINE           DB 2 DUP (10)                  ;save current line
  22. ;----------------------------------------------------------------------
  23. ;  fn_table - table contains the actual NETBIOS Control Block command
  24. ;  field.
  25. ;  The fn_table will be mapped against the message table to produce the
  26. ;  right request to be displayed on the CRT
  27. ;----------------------------------------------------------------------
  28.  
  29. FN_TABLE        DB      00H, 01H, 03H, 05H, 06H, 08H, 09H, 0AH, 0BH
  30.                 DB      0DH, 0EH, 0FH, 011H, 012H, 013H, 014H, 015H, 016H
  31.                 DB      017H, 018H, 019H, 01AH, 021H, 022H, 023H, 024H, 026H
  32.                 DB      0FFH, 04FH, 05FH
  33. LEN_FN_TABLE    EQU     $-OFFSET FN_TABLE
  34.  
  35. ;----------------------------------------------------------------------
  36. ;  message table of NETBIOS Control Block commands
  37. ;----------------------------------------------------------------------
  38. MSG_TABLE       LABEL   BYTE
  39.  
  40. DB "Good Return Code",0,"Invalid Buffer Length",0,"Illegal Command Code",0
  41. db "Command Time-out",0,"Message Buffer Too Small",0
  42. db "Session Number Not Active",0,"No Space In Adapter",0,"Session Is Closed",0
  43. db "Command Was Canceled",0,"Duplicate Name In Local Table",0
  44. Db "Local Name Table Is Full",0,"Deleted Name Is Active",0
  45. Db "Local Session Table Is Full",0,"Listen Not Outstanding On Remote CPU",0
  46. Db "Illegal Name Number",0,"Cannot Find Name / No Answer",0
  47. Db "Name Not Found In Local Table",0,"Name In Use Elsewhere",0
  48. Db "Name Deleted / No Outstanding Commands",0,"Session Ended Abnormally",0
  49. Db "Netbios Two Or More Active Names",0
  50. Db "Incompatible Packet Protocol Received",0,"Interface Busy",0
  51. Db "Too Many Commnads Outstanding",0,"Bad NCB_LANA_NUM Field",0
  52. Db "Cancel Request / No Pending Commands",0,"Command Is Illegal To Cancel",0
  53. Db "Command Is Still Pending",0,"Undeterminable Network Error",0
  54. Db "Adapter Has Malfunctioned",0
  55.  
  56. ;----------------------------------------------------------------------
  57. ;  Intercept the NETBIOS call and display what call was made.
  58. ;----------------------------------------------------------------------
  59. NETBIOS_INT       PROC    FAR
  60.         ASSUME  CS:CSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
  61.  
  62.         STI
  63.         PUSHF
  64.         CALL    OLD_NETBIOS                     ;call 5CH interrupt
  65.                                                 ; for processing
  66.         CALL    LOAD_MSG                        ;get network control
  67.                                                 ; block command and
  68.                                                 ;display message
  69.         IRET                                    ;return from interrupt
  70.  
  71. NETBIOS_INT       ENDP
  72.  
  73. ;----------------------------------------------------------------------
  74. ;  Look up the function number in the table and get English equivalent.
  75. ;----------------------------------------------------------------------
  76. LOAD_MSG          PROC    NEAR
  77.         ASSUME  CS:CSEG, DS:NOTHING, ES:NOTHING, SS:NOTHING
  78.  
  79.                 PUSH    AX                       ;save registers
  80.                 PUSH    BX
  81.                 PUSH    CX
  82.                 PUSH    DX
  83.                 PUSH    SI
  84.                 PUSH    DI
  85.                 PUSH    BP
  86.                 PUSH    DS
  87.                 PUSH    ES
  88.  
  89.                 PUSH    CS
  90.                 POP     DS
  91.         ASSUME  DS:CSEG                         ;Tell the assembler
  92.                 MOV     AH,BYTE PTR ES:[BX+1]   ;Get network control
  93.                                                 ;block return code
  94.                 MOV     SI,OFFSET FN_TABLE      ;Source of numbers
  95.                 MOV     CX,LEN_FN_TABLE         ;Quantity to search
  96.  
  97. ;----------------------------------------------------------------------
  98. ;  Routine to find network error or bad adapter
  99. ;----------------------------------------------------------------------
  100.                 CMP     AH,03FH
  101.                 JLE     LM_0
  102.                 CMP     AH,04FH                 ;undetermined network
  103.                 JG      LM_5F                   ;error?
  104.                 MOV     AH,04FH
  105. LM_5F:
  106.                 CMP     AH,0FEH                 ;adapter malfunction ?
  107.                 JG      LM_0
  108.                 MOV     AH,05FH
  109. LM_0:
  110.                 LODSB                           ;Get function number in AL
  111.                 CMP     AH,AL                   ;Match?
  112.                 JE      LM_1                    ;Yes, translate
  113.                 LOOP    LM_0                    ;No, loop again
  114.                 JMP     LM_EXIT                 ;No match found
  115.  
  116. ;----------------------------------------------------------------------
  117. ;  Found a matching function. Use msg # total_msgs - cx
  118. ;----------------------------------------------------------------------
  119. LM_1:
  120.                 MOV     AH,CL
  121.                 MOV     CX,LEN_FN_TABLE
  122.                 MOV     SI,OFFSET MSG_TABLE     ;Source of messages
  123. LM_2:
  124.                 CMP     AH,CL                   ;Does msg count = target?
  125.                 JE      LM_4                    ;Yes, go print
  126. LM_3:
  127.                 LODSB                           ;Get char
  128.                 OR      AL,AL                   ;If not 0
  129.                 JNZ     LM_3                    ; keep scanning
  130.                 LOOP    LM_2                    ; and try for match
  131. LM_4:
  132. ;----------------------------------------------------------------------
  133. ;  SI points at the start of the message.
  134. ;----------------------------------------------------------------------
  135.                 MOV     AH,03                   ;read cursor position
  136.                 MOV     BH,0
  137.                 INT     10H
  138.                 PUSH    DX                      ;Save row/col
  139.  
  140.                 MOV     AH,02                   ;Set cursor position
  141.                 MOV     DL,45                   ;at column 45
  142.  
  143. ;----------------------------------------------------------------------
  144. ;  increment the display line for command audit : up to 23 lines
  145. ;----------------------------------------------------------------------
  146.                 MOV     DH,NCBLINE               ;move line variable
  147.                                                  ;into dh
  148.                 INC     DH                       ;add 1 to next line
  149.                 CMP     DH,23                    ;is line >= 23 ?
  150.                 JLE     SHORT LM_P               ;yes then line = 0
  151.                 MOV     DH,0
  152. LM_P:
  153.                 MOV     NCBLINE,DH               ;save line number
  154.                 MOV     BH,0
  155.                 INT     10H
  156.                 MOV     AX,0920H                 ;clear display area
  157.                 XOR     BH,BH
  158.                 MOV     BL,31H
  159.                 MOV     CX,35
  160.                 INT     10H
  161. LM_5:
  162.                 LODSB                            ;load message string
  163.                 OR      AL,AL                    ;end of string ?
  164.                 JZ      LM_6                     ;yes jump lm_6
  165.                 MOV     AH,0EH                   ;write character
  166.                 INT     10H
  167.                 JMP     LM_5                     ;anymore characters ?
  168. LM_6:
  169.                 MOV     AH,02                   ;Set cursor position
  170.                 MOV     DL,45                   ;at column 45
  171.                 INC     DH                      ;check next line
  172.                 CMP     DH,23                   ;next line >= 23 ?
  173.                 JLE     SHORT LM_P1             ;yes, line = 0
  174.                 MOV     DH,0
  175. LM_P1:
  176.                 XOR     BH,BH
  177.                 INT     10H
  178.  
  179.                 MOV     AX,0920H                 ;clear next line
  180.                 MOV     BL,31H                   ;make line blue
  181.                 MOV     CX,35                    ;clear all attributes
  182.                 INT     10H                      ;up to 35 spaces
  183.  
  184.                 POP     DX                       ;restore cursor location
  185.                 MOV     AH,02
  186.                 MOV     BH,0
  187.                 INT     10H
  188. LM_EXIT:
  189.                 POP     ES                       ;restore registers
  190.                 POP     DS
  191.                 POP     BP
  192.                 POP     DI
  193.                 POP     SI
  194.                 POP     DX
  195.                 POP     CX
  196.                 POP     BX
  197.                 POP     AX
  198.  
  199.                 RET
  200.  
  201. LOAD_MSG          ENDP
  202.  
  203. ;======================================================================
  204. ;  Grab the interrupt vector.
  205. ;----------------------------------------------------------------------
  206. INITIALIZE:
  207.         ASSUME  CS:CSEG,DS:CSEG
  208.  
  209.         MOV     AL,5CH                           ;get netbios interrupt
  210.         MOV     AH,35H
  211.         INT     21H
  212.         MOV     WORD PTR OLD_NETBIOS,BX          ;store netbios interrupt
  213.         MOV     WORD PTR OLD_NETBIOS[2],ES
  214.         MOV     DX,OFFSET NETBIOS_INT            ;replace netbios interrupt
  215.                                                  ;with start of program
  216.         MOV     AL,5CH
  217.         MOV     AH,25H
  218.         INT     21H
  219.  
  220.         MOV     DX,(OFFSET INITIALIZE - OFFSET CSEG + 15 ) SHR 4
  221.     MOV    AX,3100H
  222.     INT    21H
  223.  
  224. CSEG    ENDS
  225.         END     START
  226.